﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MedievalGameProject
{
    public class Scorekeeper
    {
        Dictionary<string, int> scoreboard = new Dictionary<string, int>();

        public void AddPlayerToScoreBoard(string name)
        {
            if (scoreboard.ContainsKey(name))
            {
                scoreboard[name] = 0;
            }  
            else
            {
                scoreboard.Add(name, 0);
            }
        }

        public void AddOneToPlayerScore(string name)
        {
            scoreboard[name]++;
        }

        public bool ScoreGreaterThanOrEqual(int x)
        {
            foreach (int value in scoreboard.Values)
            {
                if(value >= x)
                    return true;
            }

            return false;
        }

        public void Clear()
        {
            List<string> names = new List<string>();

            foreach (string name in scoreboard.Keys)
                names.Add(name);

            foreach (string name in names)
                scoreboard[name] = 0;
        }

        public override string ToString()
        {
            string rval = "";

            foreach (string name in scoreboard.Keys)
                rval += name + ": " + scoreboard[name] + "\n";

            return rval;
        }
    }
}
